//
// Created by fanghr on 17-12-28.
//

#ifndef PROJECT_IMU_DATA_PACK_H
#define PROJECT_IMU_DATA_PACK_H

#include "../include.h"
#include "imu/imu_protocal.h"
#include "imu_req_pack.h"

class imu_data_pack {
public:
    struct table_t {
        friend class boost::serialization::access;

        imu_time time;
        imu_quaternion quaternion;
        imu_frame frame;
        imu_pressureAndHeightOutput pressureAndHeightOutput;
        imu_latitudeAndLongitudeOutput latitudeAndLongitudeOutput;
        imu_angularVelocity angularVelocity;
        imu_magneticOutput magneticOutput;
        imu_portStatus portStatus;
        imu_angle angle;
        imu_groundSpeed groundSpeed;

        template<class Archive>
        void serialize(Archive &ar, const unsigned int) {
            ar & time
            & quaternion
            & frame
            & pressureAndHeightOutput
            & latitudeAndLongitudeOutput
            & angularVelocity
            & magneticOutput
            & portStatus
            & angle
            & groundSpeed;
        }
    };

private:
    friend class boost::serialization::access;

    table_t table;
    imu_req_pack req_pack;

    template<class Archive>
    void serialize(Archive &ar, const unsigned int) {
        ar & table & req_pack;
    }

public:
    imu_data_pack() {}

    imu_data_pack(imu_time time,
                  imu_quaternion quaternion,
                  imu_frame frame,
                  imu_pressureAndHeightOutput pressureAndHeightOutput,
                  imu_latitudeAndLongitudeOutput latitudeAndLongitudeOutput,
                  imu_angularVelocity angularVelocity,
                  imu_magneticOutput magneticOutput,
                  imu_portStatus portStatus,
                  imu_angle angle,
                  imu_groundSpeed groundSpeed,
                  imu_req_pack req_pack
    ) {
        this->req_pack = req_pack;
        table.time = time;
        table.quaternion = quaternion;
        table.frame = frame;
        table.pressureAndHeightOutput = pressureAndHeightOutput;
        table.latitudeAndLongitudeOutput = latitudeAndLongitudeOutput;
        table.angularVelocity = angularVelocity;
        table.magneticOutput = magneticOutput;
        table.portStatus = portStatus;
        table.angle = angle;
        table.groundSpeed = groundSpeed;
    }

    table_t get() {
        return table;
    }

    imu_req_pack get_req() {
        return req_pack;
    }
};

#endif //PROJECT_IMU_DATA_PACK_H
